package utils

import (
	"github.com/astaxie/beego"
	"github.com/aliyun/alibaba-cloud-sdk-go/services/dysmsapi"
)

func SMSXsend(phone, code string) string {
	client, err := dysmsapi.NewClientWithAccessKey("cn-hangzhou", "LTAI4G4FKNYRW2gHHf38Gqhq", "C06oZc37kqtTcQ3yAxfUEz5nBi04QC")

	request := dysmsapi.CreateSendSmsRequest()
	request.Scheme = "https"

	request.PhoneNumbers = phone
	request.SignName = "皇家baby"
	request.TemplateCode = "SMS_206741870"
	request.TemplateParam = "{\"code\":\"" + code + "\"}"

	response, err := client.SendSms(request)
	if err != nil {
		beego.Error(err,response)
		return ""
	}
	return response.Code
}


